package timeUtils

import (
	"fmt"
	"time"
)

// 获取当前时间戳秒级
func GetTimestamp() int64 {
	return time.Now().Unix()
}

// 获取凌晨时间戳
func GetTodayZeroUnix() int64 {
	now := time.Now()
	today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()).Unix()
	return today
}

// 时间搓 2 time.Time
func TimestampToTime(timestamp int64) time.Time {
	return time.Unix(timestamp, 0)
}

// 今日时间转字符串
func GetTodayZeroByTime(timestamp int64) string {
	t := TimestampToTime(timestamp)
	return fmt.Sprintf("%d%02d%02d", t.Year(), t.Month(), t.Day())
}

// 获取当前时间戳毫秒级
func GetTimestampMillisecond() int64 {
	return time.Now().UnixNano() / int64(time.Millisecond)
}

// 获取当前时间
func GetNowTimeDate() string {
	currentTime := time.Now()
	formattedTime := currentTime.Format("2006-01-02 15:04:05")
	return formattedTime
}

// 时间转字符串
func TimeToString(t time.Time) string {
	formattedTime := t.Format("2006-01-02 15:04:05")
	return formattedTime
}
